#ifndef __BSP_ADC_RELATION_H_
#define __BSP_ADC_RELATION_H_

#include "main.h"
#include "stdio.h"
#include "stdint.h"

#define ADC_REF_VOL      (float)3.3            /*!< refrence voltage uinit is mv */
#define ADC_RANGE        (float)4096.0           /*!< adc full range 4096 */
#define RATE_K           (float)1000.0        /* the rate between V with mV */


#define R43                            11.3
#define R45                            20

#define R213                           10
#define R214                           10
#define R215                           1

#define VIN_VOL_GAIN                   (float)8.2
#define R364                           1000
#define R365                           10
#define R366                           1
#define R371                           1
#define RIN                            22

#define VDD33                         (float)3.3 
#define R277                           200
#define THOUSAND                      (float)1000.0


#define HO_VREF_BAT                    2500
#define HO_SENSITIVITY_BAT             16

#define VOL_COEFFICIENT                 (float)1.0
#define BAT_VOL_OFFSET                  (float)0
#define BAT_CURR_COEFFICIENT            (float)1.0
#define BAT_CURR_OFFSET                 (float)0
    
#define BAT_INTERNAL_RESISTANCE         (float)0


typedef struct
{
    uint16_t    cur_ref_vol;
    
    float       vol_coefficient;
    float       bat_vol_offset;
    
    float       bat_curr_coefficient;
    float       bat_curr_offset;
    
    float       bat_internal_resistance;   /* the battery internal resistance */
    
}adc_param_t;



/**
 * \brief    :convert the input voltage from converted value
 * \detail   :
 *
 * \param [in]: uint16_t adc_converted value
 *
 * \retval :  the input voltage uinit is mv
 * \retval :
 */
uint32_t get_bat_voltage_by_converted_value(uint16_t converted_value);

/**
 * \brief    :convert the input current from converted value
 * \detail   :
 *
 * \param [in]: uint16_t adc_converted value
 *
 * \retval :  the input current uinit is mA
 * \retval :
 */
int32_t get_bat_current_by_converted_value(uint16_t converted_value);
 
/**
 * \brief    :convert the input voltage from converted value
 * \detail   :
 *
 * \param [in]: uint16_t adc_converted value
 *
 * \retval :  the input voltage uinit is mV
 * \retval :
 */

int32_t get_vin_voltage_by_converted_value(uint16_t converted_value);



/**
 * \brief    :convert the adc temperature from converted value
 * \detail   :
 *
 * \param [in]: uint16_t adc_converted value
 *
 * \retval :  the temperatue unis is cles
 * \retval :
 */
int16_t get_temperature_out_board_by_converted_value(uint16_t converted_value);



/**
 * \brief    :convert the adc temperature from converted value in board
 * \detail   :
 *
 * \param [in]: uint16_t adc_converted value
 *
 * \retval :  the temperatue unis is cles
 * \retval :
 */
int16_t get_temperature_in_board_by_converted_value(uint16_t converted_value);



#endif
